<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>解析配置字符串</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.parse-ini-file.html">« parse_ini_file</a></li>
      <li style="float: right;"><a href="function.pathinfo.html">pathinfo »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.filesystem.html">文件系统函数</a></li>
    <li>解析配置字符串</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.parse-ini-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">parse_ini_string</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">parse_ini_string</span> &mdash; <span class="dc-title">解析配置字符串</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.parse-ini-string-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>parse_ini_string</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$ini_string</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$process_sections</code><span class="initializer"> = <strong><code>false</code></strong></span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$scanner_mode</code><span class="initializer"> = <strong><code>INI_SCANNER_NORMAL</code></strong></span></span>): <span class="type"><span class="type">array</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>parse_ini_string()</strong></span> 返回 <code class="parameter">ini_string</code> 字符串解析后的关联数组。
  </p>
  <p class="para">
   ini 字符串的格式参考 <var class="filename">php.ini</var>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.parse-ini-string-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">ini_string</code></dt>

     <dd>

      <p class="para">
       ini 字符串内容。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">process_sections</code></dt>

     <dd>

      <p class="para">
       设置 <code class="parameter">process_sections</code> 参数为 <strong><code>true</code></strong>，得到一个多维数组，包含名称和设置。<code class="parameter">process_sections</code> 默认为 <strong><code>false</code></strong>。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">scanner_mode</code></dt>

     <dd>

      <p class="para">
       可以是 <strong><code>INI_SCANNER_NORMAL</code></strong> (默认)或 <strong><code>INI_SCANNER_RAW</code></strong>。如果是 <strong><code>INI_SCANNER_RAW</code></strong>，那么选项值不会被解析。
      </p>
      <p class="para">
    As of PHP 5.6.1 can also be specified as <strong><code>INI_SCANNER_TYPED</code></strong>.
    In this mode boolean, null and integer types are preserved when possible.
    String values <code class="literal">&quot;true&quot;</code>, <code class="literal">&quot;on&quot;</code> and <code class="literal">&quot;yes&quot;</code>
    are converted to <strong><code>true</code></strong>. <code class="literal">&quot;false&quot;</code>, <code class="literal">&quot;off&quot;</code>, <code class="literal">&quot;no&quot;</code>
    and <code class="literal">&quot;none&quot;</code> are considered <strong><code>false</code></strong>. <code class="literal">&quot;null&quot;</code> is converted to <strong><code>null</code></strong>
    in typed mode. Also, all numeric strings are converted to integer type if it is possible.
   </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.parse-ini-string-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   执行成功返回一个关联数组，返回 <strong><code>false</code></strong> 为失败。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.parse-ini-string-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    有些保留字不能作为 ini
    文件中的键名，包括：<code class="literal">null</code>、<code class="literal">yes</code>、<code class="literal">no</code>、<code class="literal">true</code>、<code class="literal">false</code>、<code class="literal">on</code>、<code class="literal">off</code>、<code class="literal">none</code>。除非使用
    <strong><code>INI_SCANNER_TYPED</code></strong> 模式，否则
    <code class="literal">null</code>、<code class="literal">off</code>、<code class="literal">no</code> 和
    <code class="literal">false</code> 的值等效于
    <code class="literal">&quot;&quot;</code>，<code class="literal">on</code>、<code class="literal">yes</code> 和 <code class="literal">true</code>
    的值等效于 <code class="literal">&quot;1&quot;</code>。字符 <code class="literal">?{}|&amp;~![()^&quot;</code>
    也不能用在键名的任何地方，而且这些字符在选项值中有着特殊的意义。   
   </span>
  </p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.parse-ini-string-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.parse-ini-file.html" class="function" rel="rdfs-seeAlso">parse_ini_file()</a> - 解析一个配置文件</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>